 //
//  WENNavViewController.m
//  仿百思不得姐
//
//  Created by wen on 2018/2/12.
//  Copyright © 2018年 wen. All rights reserved.
//  代码上下挪动 cmd + alt +[

#import "WENNavViewController.h"

@interface WENNavViewController ()

@end

@implementation WENNavViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
}

/**
 当第一次来到这个类的时候会调用一次,以后不会再执行
 */
+ (void)initialize {
    //设置主题
    //指定类主题
    UINavigationBar *bar = [UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[self class]]];
    
    [bar setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:UIBarMetricsDefault];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    NSLog(@"%s",__func__);
//    viewController.view;//我们控制器的view是懒加载
    
    //自定义左上角返回按钮
    //需要判断:如果是栈底控制器,我们就不换
    if (self.childViewControllers.count > 0) {
        
        //如果想要隐藏,那么必须在push前先设置
        viewController.hidesBottomBarWhenPushed = YES;
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem backItemWithImageNamed:@"navigationButtonReturn" title:@"返回" target:self action:@selector(back)];
    }
    
    [super pushViewController:viewController animated:animated];
    
    
}

- (void)back {
    [self popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
